perm filename LOOK.FAI[HAK,HPM]2 blob sn#234041 filedate 1976-08-30 generic text, type C, neo UTF8
COMMENT āŠ—   VALID 00002 PAGES
C REC  PAGE   DESCRIPTION
C00001 00001
C00002 00002		title	/look/
C00005 ENDMK
CāŠ—;
	title	/look/
start:	movni	1,1		;getlin wants neg arg
	getlin	1		;get the line number
	tlnn	1,20000		;is it a dd?
	jrst	[outstr	[asciz	/ Not a data disk, can't map
/]
		exit]
	subi	1,20		;make it a physical line number
	hrrm	1,line		;deposit line number
	move	1,[400017,,map]	;setup word for spacewar process
	spcwgo	1,
	setom	allook#		;default to looking at all channels

loop:	skipe	allook
	jrst	all
	move	1,[-40,,0]
	setzm	dduse#
	movsi	3,400000
gdd:	movei	2,200(1)
	ddchan	2,
	tlnn	2,200		;only look at channels which are not system
	tlnn	2,377		;and are in use by somebody
	skipa
	iorm	3,dduse
	lsh	3,-1
	aobjn	1,gdd
	skipa
all:	setom	dduse
	inchrw	1
	cain	1,"+"
	jrst	forwrd
	cain	1,"-"
	jrst	backwd
	cain	1,15		;carriage return to exit
	exit
	caie	1,"n"
	cain	1,"N"
	jrst	normal
	caie	1,"r"
	cain	1,"R"
	jrst	rinuse
	setzm	direct		;set direction to 0 to stop movement
	jrst	loop
forwrd:	movei	2,1		;set direction forward
	skipa
backwd:	movei	2,-1		;set direction backward
	movem	2,direct
	jrst	loop
normal:	setom	allook		;set looking at all channels
	jrst	loop
rinuse:	setzm	allook		;set looking at in use only channels
	jrst	loop

map:	sosle	timec		;n'th tic?
	dismis			;no
	movei	10,4		;default n = 4 for 1 map per second
	movem	10,timec
map1:	skipe	dduse		;get out if not looking at any channels
	skipn	direct		;aren't moving
	dismis
	move	10,direct
	addb	10,chanel	;current dd channel being looked at
	andi	10,37		;mask out all but bottom 5 bits
	movn	10,10		;prepare for shift right
	hrlzi	11,400000
	lsh	11,(10)
	and	11,dduse
	jumpe	11,map1		;try again if we're not looking at this one
line:	cono	340,21		;default line is mine
	datao	340,11
byebye:	dismis

timec:	0			;start with 1 map per second
chanel:	0			;initial chanel is 0
direct:	1			;initial direction is forward

	end	start